<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="shiyue" uri="http://www.shiyue.com" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%--
 /**
  功能名称:教师列表
  
  创建人:
*/
--%>
<%
String path = request.getContextPath();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>教师列表</title>
	<link href="<%=path%>/css/index_css.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" type="text/css" href="<%=path %>/css/paging.css">
	<script src="<%=path%>/js/resizeIframe.js" type="text/javascript"></script>
	<script src="<%=path%>/js/syAjax.js" type="text/javascript"></script>
	<script language="javascript" src="<%=path %>/js/paging.js"></script>
	<script src="<%=path%>/dwr/engine.js"></script>
	<script src="<%=path%>/dwr/util.js"></script>
	<script src="<%=path%>/dwr/interface/shiyueDwr.js"></script>
	<script type="text/JavaScript">
	var pageInfo = ${shiyue:toJSONWithExclude(pageInfo, "class,pageData")};
	window.onload   =   function(){
		objURL= "<%=path%>/findAllUserByTypeAndStatusUserAction.action?user.userType=2&user.status=1&currentPage=${currentPage}";
		if('${requestScope.pageURL}'!=null && '${requestScope.pageURL}'!=""){
			objURL='${requestScope.pageURL}';
		}
		paging(objURL,pageInfo);
		shiyueDwr.findOrganizationBytype(2,'${UNITTYPE}',findOrganizationByTypeCallBack);
    	shiyueDwr.findCodeByCodeMaintenanceTypeId("sex",getsexCallBack);
        resizeIframe();
        parent.location.hash="top";
        document.getElementsByName("img").src+="&t="+new Date();
	}
	
	
	function checkAll(){
		var chk1 = document.getElementById('chk1');
		var arr=document.getElementsByName('checkbox2');
		for(var i=0;i<arr.length;i++){
			arr[i].checked=chk1.checked;
		}
		
	}
	
	function doDelete(){
		
			var userIds="";
			var checkedCount=0;
			var arr=document.getElementsByName('checkbox2');
			for(var i=0;i<arr.length;i++){
				if(arr[i].checked){
					checkedCount++;
					userIds+=arr[i].value+",";
				}
			}
			if(checkedCount==0){
				alert('请选择要删除的信息！');
			}else{
				if(confirm('确定要删除吗？')){
					document.getElementById('UserIds').value=userIds;
					document.forms[0].submit();
				}
			}
		
		
		
	}
	
	function toStuList(){
		window.location.href='<%=path%>/findAllUserByTypeAndStatusUserAction.action?user.userType=1&user.status=1';
	}
	
    
    var saveOrgId="";//部门id
    function doAddTeacher(){
    	saveOrgId=document.getElementById('department').value;
 		var returnStr=window.showModalDialog("<%=path%>/toSaveUserAction.action?user.userType=2&saveOrgId="+saveOrgId+"&t="+new Date(),"","dialogHeight:450px;dialogWidth:700px;help=0;scroll=1;");   	
    		if(returnStr=="true"){
    			if(saveOrgId==""){
    				window.location.href="findAllUserByTypeAndStatusUserAction.action?user.userType=2&user.status=1";
    			}else{
    				window.location.href="selectUserByOrgIdAndYearAndUnitIdorganizationAction.action?user.userType=2&user.status=1&organization.organizationId="+saveOrgId+"&role.roleId=member&years=${applicationScope.currentYear}&ispageURL=true";
    			}    	
    			
    		}			
    }
    
   
    

    
    
    
    //更新教师信息
    function doUpdateTeacher(userId){
    
    		var returnStr=window.showModalDialog("<%=path%>/toUpdateUserAction.action?user.userId="+userId+"&t="+new Date(),"","dialogHeight:367px;dialogWidth:658px;help=0;scroll=1;");   	
    		if(returnStr=="true"){   	
    			window.location.href="findAllUserByTypeAndStatusUserAction.action?user.userType=2&user.status=1";
    		}
    	
    }
    

    
    	function findOrganizationByTypeCallBack(orgMap) {
		  DWRUtil.removeAllOptions("department");
		  var i=0;
		  for(var j in orgMap) {			//判断对象里没有元素 闷男 2012-8-1314 （不是最好方法）
		  	i++;
		  }
		  if(i==0) {   				//如果orgMap 没有元素则加个请选择
		   	var op=document.createElement("option");
            op.innerHTML="---请选择---";
            document.getElementById("department").appendChild(op);
		  }else {
		  	 DWRUtil.addOptions("department", orgMap);
		  	  if('${ORGID}'!='')
		      {
		        document.getElementById("department").value="${ORGID}";
		      }
		  }
		  	
	     
	     
      }  
      


    
 
    
     	//性别
    function getsexCallBack(map)
    {
      <c:if test="${requestScope.UserList!=null}">
      <c:forEach items="${requestScope.UserList}" var="p">
      	if(map["${p.sex}"]!=undefined){
      		document.getElementById("${p.userId}Sex").innerHTML=map["${p.sex}"];
      	}
      </c:forEach>
      </c:if>
    }
     
  
     
     function changeDepartment(orgId){
    
     		if(orgId==""){
     			window.location.href='findAllUserByTypeAndStatusUserAction.action?user.userType=2&user.status=1';
     		}else{
     			window.location.href="selectUserByOrgIdAndYearAndUnitIdorganizationAction.action?user.userType=2&user.status=1&organization.organizationId="+orgId+"&role.roleId=member&years=${applicationScope.currentYear}&ispageURL=true";
     		}
     	
     }
     
     function searchUser(){
     	var UserName=document.getElementById("username").value;
		var orgId=document.getElementById("department").value;
		UserName=encodeURI(UserName);
		if(orgId==""){
   			window.location.href="findUsersByTypeAndUnitAndNameAndStatusUserAction.action?user.userType=2&user.status=1&user.name="+UserName;
   		}else{
   			window.location.href="selectUserByOrgIdAndYearAndNameorganizationAction.action?user.userType=2&user.status=1&organization.organizationId="+orgId+"&role.roleId=member&years=${applicationScope.currentYear}&ispageURL=true&user.name="+UserName;
   		}
     }     
     function doExportExcel(){
     	window.open("<%=path%>/baseSet/user/batchGetTeacher.jsp?userType=2","2","height=250px,width=700px,scrollbars=1;");
     }
     
      //批量导入
     function doImportExcel(){
  
     		
     		document.getElementById('excelbackURL').value="findAllUserByTypeAndStatusUserAction.action?user.userType=2&user.status=1";
     		document.excelForm.submit();
     		
     	
     	
     }

    
     
        function doSomeUpdate(){
     	var userIds="";
			var checkedCount=0;
			var arr=document.getElementsByName('checkbox2');
			for(var i=0;i<arr.length;i++){
				if(arr[i].checked){
					checkedCount++;
					userIds+=arr[i].value+",";
				}
			}
			if(checkedCount==0){
				alert('请选择要批量修改的用户！');
			}else{
				window.open("<%=path%>/tobatchUpdateUserUserAction.action?userIds="+userIds);
				
			}
     }
     
     // 2011.4.14 LiuYJ 添加点击查看权限功能
     
    function selectPermissions(userId){
 
    		var returnStr=window.showModalDialog("<%=path%>/toFindRoleUserAction.action?flage1="+7+"&user.userId="+userId+"&t="+new Date(),"","dialogHeight:367px;dialogWidth:658px;help=0;scroll=1;");   	
    		if(returnStr=="true"){   	
    			window.location.href="findAllUserByTypeAndStatusUserAction.action?user.userType=2&user.status=1";
    		}
    	
    }
     
   function cnfPermissions (userId,account) {
	window.open("<%=path%>/toUserRoleSetroleAction.action?user.userId="+userId+"&user.account="+account+"&t="+new Date());   	
   } 
  
     //修改用户状态－－新添加  2012-3-6
     var UserIdTD;
     var UserStatus;
     function updateStatus(userId,status,message){
      if(confirm(message)){
        UserIdTD=userId;
        UserStatus=status;
        shiyueDwr.updateUserStatus(userId,status,updateUserStatusCallBack);
        
      }    
     } 
     function updateUserStatusCallBack(result){
        if(result=='true'){
        alert('设置成功！');
        if(UserStatus==1){
        document.getElementById(UserIdTD+'TD').innerHTML="在职&nbsp;&nbsp;<a href=\"javascript:updateStatus('"+UserIdTD+"',2,"+"'确定设为离职吗？'"+');"><img alt="设为离职" src="<%=path %>/images/status1.gif" width="15" height="16" border="0" /></a>';
           }else if(UserStatus==2){
        document.getElementById(UserIdTD+'TD').innerHTML="离职&nbsp;&nbsp;<a href=\"javascript:updateStatus('"+UserIdTD+"',1,"+"'确定设为在职吗？'"+');"><img alt="设为在职" src="<%=path %>/images/status2.gif" width="15" height="16" border="0" /></a>';
           }                         
        }else{
        alert('设置失败！');
        }      



     }   
     
	</script>

  </head>
  
  <body>
  <form action="deleteUserAction.action" method="post">
  <input id="userIds" type="hidden" name="userIds" value="" />
  <input type="hidden" name="user.userType" value="${user.userType }" />
  <input type="hidden" name="user.status" value="${user.status }" />
  <input type="hidden" name="year" value="${applicationScope.currentYear}"/>
  <input type="hidden" name="isStuOrTea" value="tea" />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="2" align="left" class="f_5">用户管理</td>
  </tr>
  <tr>
    <td height="1" colspan="2" bgcolor="#9DD12E"></td>
  </tr>
  <tr>
    <td colspan="2" align="left" valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" align="left"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="left" valign="bottom" background="<%=path %>/images/sywesp_24.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>

          
          
            <td width="90" align="left">
            <table width="90" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="1" align="left" valign="bottom" bgcolor="#CBCBCB"></td>
                <td align="center" background="<%=path %>/images/sywesp_25.gif" class="f_9">
              教师用户        
                </td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table>
            </td>
            <td width="5" align="left">&nbsp;</td>
            
            
            <td width="90" align="left">
            <table width="90" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="1" align="left" valign="bottom" bgcolor="#CBCBCB"></td>
                <td align="center" background="<%=path %>/images/sywesp_18.gif" style="cursor:pointer;" onclick="toStuList();" class="f_6">学生用户</td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table>
            </td>
            <td align="left">&nbsp;</td>
            
            </tr>
            
        </table></td>
      </tr>
      <tr>
        <td align="left" valign="top" class="tb_8 border_2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="25" align="right" bgcolor="#FFFFFF" class="f_6">
              	
              	学校部门：
                <select id="department" onchange="changeDepartment(this.value);" name="department">
                  <option value="">---请选择---</option>
                </select>

              <span style="margin-left:20px;white-space:nowrap"><label for="username">帐号/姓名</label><input id="username" value="${requestScope.user.name }" name="name" type="text" style="width:100px" maxlength="16"/>
              <button type="button" onclick="searchUser();" style="margin-left:4px;">搜索</button>
              </span>
              </td>
              </tr>
            <tr>
              <td height="30" align="right" valign="bottom" background="<%=path %>/images/sywesp_26.gif"><a href="javascript:doAddTeacher();"  ><img src="<%=path %>/images/icon_newuser.gif" name="Image11" width="85" height="24" border="0" id="Image11" /></a>&nbsp;<a href="javascript:doImportExcel();"  ><img src="<%=path %>/images/icon_dr.gif" name="Image10" width="99" height="24" border="0" id="Image10" /></a>&nbsp;<a href="<%=path %>/baseSet/user/batchAddImage.jsp?paramUserType=2"  ><img src="<%=path %>/images/icon_dr2.gif" name="Image10" width="99" height="24" border="0" id="Image10" /></a>&nbsp;<a href="javascript:doExportExcel();"  ><img src="<%=path %>/images/icon_dc.gif" name="Image9" width="99" height="24" border="0" id="Image9" /></a>&nbsp;<a href="javascript:doDelete();"  ><img src="<%=path %>/images/icon_delete.gif" name="Image8" width="57" height="24" border="0" id="Image8" /></a>&nbsp;&nbsp;<a href='javascript:doSomeUpdate();'  ><img src="<%=path %>/images/icon_sywesp_0125_1.gif" name="Image125" width="75" height="24" border="0" id="Image125" /></a></td>
            </tr>
            <tr>
              <td height="30" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td width="2" height="24" align="left" background="<%=path %>/images/sywesp_21.gif"><img src="<%=path %>/images/sywesp_20.gif" width="2" height="24" /></td>
                              <td align="left" background="<%=path %>/images/sywesp_21.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                  <tr>
                                    <td width="1%">&nbsp;</td>
                                    <td width="8%" align="left" class="f_8"><img src="<%=path %>/images/sywesp_23.gif" width="8" height="22" align="absmiddle" />头像</td>
                                    <td width="26%" align="left" class="f_8"><img src="<%=path %>/images/sywesp_23.gif" width="8" height="22" align="absmiddle" />编号</td>
                                    <td align="left" class="f_8"><img src="<%=path %>/images/sywesp_23.gif" width="8" height="22" align="absmiddle" />帐号：姓名</td>
                                    <td width="6%" align="left" class="f_8"><img src="<%=path %>/images/sywesp_23.gif" width="8" height="22" align="absmiddle" />性别</td>
                                    <td width="10%" align="left" class="f_8"><img src="<%=path %>/images/sywesp_23.gif" width="8" height="22" align="absmiddle" />手机号码</td>
                                    <td width="8%" align="left" class="f_8"><img src="<%=path %>/images/sywesp_23.gif" width="8" height="22" align="absmiddle" />权限</td>
                                    <td width="6%" align="left" class="f_8"><img src="<%=path %>/images/sywesp_23.gif" width="8" height="22" align="absmiddle" />状态</td>
                                    <td width="5%" align="left" class="f_8"><img src="<%=path %>/images/sywesp_23.gif" width="8" height="22" align="absmiddle" />操作</td>
                                    <td width="3%" align="left" class="f_8"><input id="chk1" type="checkbox" onclick="checkAll();" name="checkbox" value="checkbox" /></td>
                                  </tr>
                              </table></td>
                              <td width="4" align="right" background="<%=path %>/images/sywesp_21.gif"><img src="<%=path %>/images/sywesp_22.gif" width="4" height="24" /></td>
                            </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td align="left" valign="top">
                        <c:if test="${requestScope.UserList!=null}">
                        <c:forEach items="${requestScope.UserList}" var="p">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td height="35" align="left" valign="top" class="tb_7"><table width="100%" border="0" cellspacing="1" cellpadding="0">
                                  <tr>
                                    <td width="1%" align="right" valign="bottom">&nbsp;</td>
                                    <td width="8%" height="35" align="center">
	                                    <c:choose>
						                <c:when test="${empty p.img }"><font color="#CCCCCC">无头像</font></c:when>
						                <c:otherwise>		                
						                <img src="${applicationScope.currentEnclosureServer.outUrl }/enclosure/${p.img}" name="img" width="26" height="35" align="middle" />
						                
						                </c:otherwise>
						                </c:choose>
                                    </td>
                                    <td width="26%" height="35" align="left" valign="bottom">${p.userId }</td>
                                    <td height="35" align="left" valign="bottom">${p.account }：${p.name }</td>
                                    <td width="6%" align="left" valign="bottom">
                                    <span id="${p.userId }Sex"></span>
                                    </td>
                                    <td width="10%" valign="bottom">${p.mobileNumber1 }</td>
                                    <td width="8%" valign="bottom"><img src="<%=path %>/images/icon_19.gif"  onclick="javascript:selectPermissions('${p.userId}');" width="15" height="16" border="0" style="cursor:pointer;" alt="设置权限"/>
                                     <c:if test="${fn:contains(sessionScope.roleIds,'sysadmin')}">
                                    <img src="<%=path %>/images/icon_20.gif" onclick="javascript:cnfPermissions('${p.userId}','${p.account}');" width="15" height="16" border="0" style="cursor:pointer;" alt="设置权限"/>
                                    </c:if>
                                    </td>
                                     <td width="6%" valign="bottom" id='${p.userId}TD'>
                                    <c:if test="${p.status==1}">在职<a href="javascript:updateStatus('${p.userId}',2,'确定设为离职吗？');"><img alt="设为离职" src="<%=path %>/images/status1.gif" width="15" height="16" border="0" /></a></c:if>
                                    <c:if test="${p.status==2}">离职<a href="javascript:updateStatus('${p.userId}',1,'确定设为在职吗？');"><img alt="设为在职" src="<%=path %>/images/status2.gif" width="15" height="16" border="0" /></a></c:if>
                                    
                                    
                                    </td>
                                    <td width="5%" valign="bottom">
                                    
                                    <a href="javascript:doUpdateTeacher('${p.userId}');"><img alt="修改用户信息" src="<%=path %>/images/icon_5.gif" width="15" height="16" border="0" /></a>
                                    
                                    </td>
                                    <td width="3%" valign="bottom">
                                    <span class="f_8">
                                    	<c:if test="${p.account!='admin'}">
                                      <input type="checkbox" name="checkbox2" value="${p.userId }" />
                                      </c:if>
                                    </span></td>
                                  </tr>
                                </table>
                                  </td>
                            </tr>
                        </table>
                        </c:forEach>
                        </c:if>
                         <c:if test="${requestScope.UserList==null}">
                        
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td height="25" align="center" valign="top" class="tb_7">
                              	暂无数据
                              </td>
                            </tr>
                        </table>
                       
                        </c:if>
                        
             
                          
                          </td>
                      </tr>
                  </table>
                  
                  </td>
                </tr>
              </table></td>
            </tr>
            <tr><td align="center" valign="top"><shiyue:paging/></td></tr>
          </table>
          </td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      
        <tr>
        <td>
        	  <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td align="left" valign="top" class="tb_9 border_3">
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td align="left"><img src="<%=path %>/images/icon_14.gif" width="62" height="17" /></td>
                </tr>
                <tr>
                                    <td height="30" align="left" valign="middle"><img src="<%=path %>/images/icon_5.gif" width="15" height="16" /> 表示修改用户信息&nbsp;&nbsp;<img src="<%=path %>/images/icon_19.gif" width="15" height="16" /> 表示查看用户权限&nbsp;&nbsp;<img src="<%=path %>/images/icon_20.gif" width="15" height="16" /> 表示设置用户权限&nbsp;&nbsp;</td>
                </tr>
              </table>
              </td>
            </tr>
          </table>
        
        </td>                                
      </tr>
      
    </table></td>
  </tr>
</table>
</form>
<form name="excelForm" id="excelForm" action="<%=path %>/toBatchAddTeacherUserAction.action" method="post">
	<input type="hidden" id="excelbackURL" name="backURL" value="<%=path %>/findAllUserByTypeAndStatusUserAction.action?user.userType=2&user.status=1">
	
</form>
</body>
</html>
